package com.astrofizzbizz.stoneedgegui.monitor;

import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;

import com.astrofizzbizz.stoneedgegui.app.StatusPanel;
import com.astrofizzbizz.stoneedgegui.app.StoneEdgeIIIGui;
import com.astrofizzbizz.stoneedgegui.utilities.StoneEdgeIIIException;
import com.astrofizzbizz.stoneedgegui.utilities.TelescopeInfo;



public class TelescopeMonitorPanel extends JPanel
{
	private static final long serialVersionUID = -8257768148525532359L;
	private JTabbedPane mainPane;
	private StatusPanel statusBar = new StatusPanel(4, "Dome Status");
	private JTextArea telescopeStatusTableTextArea  = new JTextArea();
	private DomeMonitorPanel domeMonitorPanel;
	private StoneEdgeIIIGui stoneEdgeIIIGui = null;
	
	public TelescopeMonitorPanel(StoneEdgeIIIGui stoneEdgeIIIGui)
	{
		this.stoneEdgeIIIGui = stoneEdgeIIIGui;
	    try {stoneEdgeIIIGui.setTelescopeInfo(new TelescopeInfo(stoneEdgeIIIGui.getStoneEdgeIIITunnel()));} 
	    catch (StoneEdgeIIIException e) {e.messageDialog(stoneEdgeIIIGui);}

		
		statusBar.setText("Welcome");
		domeMonitorPanel = new DomeMonitorPanel(this);
		mainPane = new JTabbedPane();
		mainPane.addTab("Camera", domeMonitorPanel);
		
		telescopeStatusTableTextArea.setRows(stoneEdgeIIIGui.getStatusTableLength());
		JScrollPane scrollPane = new JScrollPane(telescopeStatusTableTextArea);
		scrollPane.setMaximumSize(new Dimension(domeMonitorPanel.getCameraWidth(),domeMonitorPanel.getCameraHeight()));
		scrollPane.setPreferredSize(new Dimension(domeMonitorPanel.getCameraWidth(),domeMonitorPanel.getCameraHeight()));
		mainPane.addTab("Status", scrollPane);
		
		setLayout(new BorderLayout(5,5));
		add(mainPane, BorderLayout.CENTER);
		add(statusBar.getScrollPane(), java.awt.BorderLayout.SOUTH);  
		
	}

	public DomeMonitorPanel getDomeMonitorPanel() {return domeMonitorPanel;}
	public StatusPanel getStatusBar() {return statusBar;}
	public JTextArea getTelescopeStatusTableTextArea() {return telescopeStatusTableTextArea;}
	public StoneEdgeIIIGui getStoneEdgeIIIGui() {return stoneEdgeIIIGui;}

	public static void main(String[] args) throws StoneEdgeIIIException 
	{
	    
	}

}
